* Change directory to location of data files *
use "Iraq_gallup_original.dta", clear

* Table 1 *
logit iraqmistake female college age i.year
outreg2 using table2, word label dec(2) sortvar(dem gop female  college age) drop(i.year)  2aster replace
logit iraqmistake female dem gop college age i.year
outreg2 using table2, word label dec(2) sortvar(dem gop female   college age) drop(i.year)  2aster append
logit iraqmistake female college age i.year  if dem == 1
outreg2 using table2, word label dec(2) sortvar(dem gop female  gopfemale college age) drop(i.year)  2aster append
logit iraqmistake female college age i.year  if gop == 1
outreg2 using table2, word label dec(2) sortvar(female   college age) drop(i.year)  2aster append
logit iraqmistake female college age i.year  if ind == 1
outreg2 using table2, word label dec(2) sortvar(female   college age) drop(i.year)  2aster append

* Figure 2 *
use "Iraq_gallup_original.dta", clear
gen counter = _n
gen female_b = .
gen female_se = .
gen female_u = .
gen group = ""
gen year_graph = .

logit iraqmistake female dem gop college age if year == 2004
replace female_b = r(table)[1,1] if counter == 1
replace female_se = r(table)[2,1] if counter == 1
replace year_graph = 2004 if counter == 1
replace group = "All" if counter == 1
logit iraqmistake female dem gop college age if year == 2005
replace female_b = r(table)[1,1] if counter == 2
replace female_se = r(table)[2,1] if counter == 2
replace year_graph = 2005 if counter == 2
replace group = "All" if counter == 2
logit iraqmistake female dem gop college age if year == 2006
replace female_b = r(table)[1,1] if counter == 3
replace female_se = r(table)[2,1] if counter == 3
replace year_graph = 2006 if counter == 3
replace group = "All" if counter == 3
logit iraqmistake female dem gop college age if year == 2007
replace female_b = r(table)[1,1] if counter == 4
replace female_se = r(table)[2,1] if counter == 4
replace year_graph = 2007 if counter == 4
replace group = "All" if counter == 4
logit iraqmistake female dem gop college age if year == 2008
replace female_b = r(table)[1,1] if counter == 5
replace female_se = r(table)[2,1] if counter == 5
replace year_graph = 2008 if counter == 5
replace group = "All" if counter == 5

logit iraqmistake female dem gop college age if year == 2004 & dem == 1
replace female_b = r(table)[1,1] if counter == 6
replace female_se = r(table)[2,1] if counter == 6
replace year_graph = 2004 if counter == 6
replace group = "Dem" if counter == 6
logit iraqmistake female dem gop college age if year == 2005 & dem == 1
replace female_b = r(table)[1,1] if counter == 7
replace female_se = r(table)[2,1] if counter == 7
replace year_graph = 2005 if counter == 7
replace group = "Dem" if counter == 7
logit iraqmistake female dem gop college age if year == 2006 & dem == 1
replace female_b = r(table)[1,1] if counter == 8
replace female_se = r(table)[2,1] if counter == 8
replace year_graph = 2006 if counter == 8
replace group = "Dem" if counter == 8
logit iraqmistake female dem gop college age if year == 2007 & dem == 1
replace female_b = r(table)[1,1] if counter == 9
replace female_se = r(table)[2,1] if counter == 9
replace year_graph = 2007 if counter == 9
replace group = "Dem" if counter == 9
logit iraqmistake female dem gop college age if year == 2008 & dem == 1
replace female_b = r(table)[1,1] if counter == 10
replace female_se = r(table)[2,1] if counter == 10
replace year_graph = 2008 if counter == 10
replace group = "Dem" if counter == 10

logit iraqmistake female dem gop college age if year == 2004 & gop == 1
replace female_b = r(table)[1,1] if counter == 11
replace female_se = r(table)[2,1] if counter == 11
replace year_graph = 2004 if counter == 11
replace group = "Gop" if counter == 11
logit iraqmistake female dem gop college age if year == 2005 & gop == 1
replace female_b = r(table)[1,1] if counter == 12
replace female_se = r(table)[2,1] if counter == 12
replace year_graph = 2005 if counter == 12
replace group = "Gop" if counter == 12
logit iraqmistake female dem gop college age if year == 2006 & gop == 1
replace female_b = r(table)[1,1] if counter == 13
replace female_se = r(table)[2,1] if counter == 13
replace year_graph = 2006 if counter == 13
replace group = "Gop" if counter == 13
logit iraqmistake female dem gop college age if year == 2007 & gop == 1
replace female_b = r(table)[1,1] if counter == 14
replace female_se = r(table)[2,1] if counter == 14
replace year_graph = 2007 if counter == 14
replace group = "Gop" if counter == 14
logit iraqmistake female dem gop college age if year == 2008 & gop == 1
replace female_b = r(table)[1,1] if counter == 15
replace female_se = r(table)[2,1] if counter == 15
replace year_graph = 2008 if counter == 15
replace group = "Gop" if counter == 15

logit iraqmistake female dem gop college age if year == 2004 & ind == 1
replace female_b = r(table)[1,1] if counter == 16
replace female_se = r(table)[2,1] if counter == 16
replace year_graph = 2004 if counter == 16
replace group = "Ind" if counter == 16
logit iraqmistake female dem gop college age if year == 2005 & ind == 1
replace female_b = r(table)[1,1] if counter == 17
replace female_se = r(table)[2,1] if counter == 17
replace year_graph = 2005 if counter == 17
replace group = "Ind" if counter == 17
logit iraqmistake female dem gop college age if year == 2006 & ind == 1
replace female_b = r(table)[1,1] if counter == 18
replace female_se = r(table)[2,1] if counter == 18
replace year_graph = 2006 if counter == 18
replace group = "Ind" if counter == 18
logit iraqmistake female dem gop college age if year == 2007 & ind == 1
replace female_b = r(table)[1,1] if counter == 19
replace female_se = r(table)[2,1] if counter == 19
replace year_graph = 2007 if counter == 19
replace group = "Ind" if counter == 19
logit iraqmistake female dem gop college age if year == 2008 & ind == 1
replace female_b = r(table)[1,1] if counter == 20
replace female_se = r(table)[2,1] if counter == 20
replace year_graph = 2008 if counter == 20
replace group = "Ind" if counter == 20

serrbar female_b female_se year_graph if group=="All", scale(1.96) xlabel(2004 2005 2006 2007 2008) ti("All", size(medsmall)) xtitle(" " "Year", size(small)) ylabel(-.2(.1).4) ytitle("Gender coefficient" " ") yline(0) graphregion(color(white)) mcolor(black) saving(all.gph, replace) yscale(range(-.225 .425))

serrbar female_b female_se year_graph if group=="Dem", scale(1.96) xlabel(2004 2005 2006 2007 2008) ti("Democrats", size(medsmall)) xtitle(" " "Year", size(small)) ylabel(-.2(.1).4) ytitle("Gender coefficient" " ") yline(0) graphregion(color(white)) mcolor(black) saving(dem.gph, replace) yscale(range(-.225 .425))

serrbar female_b female_se year_graph if group=="Gop", scale(1.96) xlabel(2004 2005 2006 2007 2008) ti("Republicans", size(medsmall)) xtitle(" " "Year", size(small)) ylabel(-.2(.1).4) ytitle("Gender coefficient" " ") yline(0) graphregion(color(white)) mcolor(black) saving(gop.gph, replace) yscale(range(-.225 .425))

serrbar female_b female_se year_graph if group=="Ind", scale(1.96) xlabel(2004 2005 2006 2007 2008) ti("Independents", size(medsmall)) xtitle(" " "Year", size(small)) ylabel(-.2(.1).4) ytitle("Gender coefficient" " ") yline(0) graphregion(color(white)) mcolor(black) saving(ind.gph, replace) yscale(range(-.225 .425))

graph combine "all.gph" "dem.gph" "gop.gph" "ind.gph", graphregion(color(white))

* Table 2 *
use "All Afghanistan mistake data appended.dta", clear

logit mistake female college age i.year  cnn maryland
outreg2 using table2, word label dec(2) sortvar(dem gop female  college age) drop(i.year)  2aster replace
logit mistake female dem gop college age i.year cnn maryland
outreg2 using table2, word label dec(2) sortvar(dem gop female   college age) drop(i.year)  2aster append
logit mistake female college age i.year cnn maryland  if dem == 1
outreg2 using table2, word label dec(2) sortvar(dem gop female  gopfemale college age) drop(i.year)  2aster append
logit mistake female college age i.year cnn maryland  if gop == 1
outreg2 using table2, word label dec(2) sortvar(female   college age) drop(i.year)  2aster append
logit mistake female college age i.year cnn maryland  if ind == 1
outreg2 using table2, word label dec(2) sortvar(female   college age) drop(i.year)  2aster append

* Figure 3 *
use "All Afghanistan mistake data appended.dta", clear
* All *
gen counter = _n
gen female_b = .
gen female_se = .
gen female_u = .
gen group = ""
gen year_graph = .

logit mistake female college age cnn maryland if year == 2004
replace female_b = r(table)[1,1] if counter == 1
replace female_se = r(table)[2,1] if counter == 1
replace year_graph = 2004 if counter == 1
replace group = "All" if counter == 1
logit mistake female college age cnn maryland if year == 2007
replace female_b = r(table)[1,1] if counter == 2
replace female_se = r(table)[2,1] if counter == 2
replace year_graph = 2007 if counter == 2
replace group = "All" if counter == 2
logit mistake female college age cnn maryland if year == 2008
replace female_b = r(table)[1,1] if counter == 3
replace female_se = r(table)[2,1] if counter == 3
replace year_graph = 2008 if counter == 3
replace group = "All" if counter == 3
logit mistake female college age cnn maryland if year == 2009
replace female_b = r(table)[1,1] if counter == 4
replace female_se = r(table)[2,1] if counter == 4
replace year_graph = 2009 if counter == 4
replace group = "All" if counter == 4
logit mistake female college age cnn maryland if year == 2010
replace female_b = r(table)[1,1] if counter == 5
replace female_se = r(table)[2,1] if counter == 5
replace year_graph = 2010 if counter == 5
replace group = "All" if counter == 5
logit mistake female college age cnn maryland if year == 2011
replace female_b = r(table)[1,1] if counter == 6
replace female_se = r(table)[2,1] if counter == 6
replace year_graph = 2011 if counter == 6
replace group = "All" if counter == 6
logit mistake female college age cnn maryland if year == 2013
replace female_b = r(table)[1,1] if counter == 7
replace female_se = r(table)[2,1] if counter == 7
replace year_graph = 2013 if counter == 7
replace group = "All" if counter == 7
logit mistake female college age cnn maryland if year == 2014
replace female_b = r(table)[1,1] if counter == 8
replace female_se = r(table)[2,1] if counter == 8
replace year_graph = 2014 if counter == 8
replace group = "All" if counter == 8
logit mistake female college age cnn maryland if year == 2015
replace female_b = r(table)[1,1] if counter == 9
replace female_se = r(table)[2,1] if counter == 9
replace year_graph = 2015 if counter == 9
replace group = "All" if counter == 9
serrbar female_b female_se year_graph if group=="All", scale(1.96) xlabel(2004 2007 2008 2009 2010 2011 2013 2014 2015, angle(90)) ti("All", size(medsmall)) xtitle(" " "Year", size(small)) ylabel(-1 -.5 0 .5 1 1.5) ytitle("Gender coefficient" " ") yline(0) graphregion(color(white)) saving(afg_all.gph, replace) yscale(range(-1.2 1.75)) mvopts(mcolor(black)) lcolor(black)

* Dem *
use "All Afghanistan mistake data appended.dta", clear
gen counter = _n
gen female_b = .
gen female_se = .
gen female_u = .
gen group = ""
gen year_graph = .

logit mistake female college age cnn maryland if year == 2004 & dem == 1
replace female_b = r(table)[1,1] if counter == 1
replace female_se = r(table)[2,1] if counter == 1
replace year_graph = 2004 if counter == 1
replace group = "Dem" if counter == 1
logit mistake female college age cnn maryland if year == 2007 & dem == 1
replace female_b = r(table)[1,1] if counter == 2
replace female_se = r(table)[2,1] if counter == 2
replace year_graph = 2007 if counter == 2
replace group = "Dem" if counter == 2
logit mistake female college age cnn maryland if year == 2008 & dem == 1
replace female_b = r(table)[1,1] if counter == 3
replace female_se = r(table)[2,1] if counter == 3
replace year_graph = 2008 if counter == 3
replace group = "Dem" if counter == 3
logit mistake female college age cnn maryland if year == 2009 & dem == 1
replace female_b = r(table)[1,1] if counter == 4
replace female_se = r(table)[2,1] if counter == 4
replace year_graph = 2009 if counter == 4
replace group = "Dem" if counter == 4
logit mistake female college age cnn maryland if year == 2010 & dem == 1
replace female_b = r(table)[1,1] if counter == 5
replace female_se = r(table)[2,1] if counter == 5
replace year_graph = 2010 if counter == 5
replace group = "Dem" if counter == 5
logit mistake female college age cnn maryland if year == 2011 & dem == 1
replace female_b = r(table)[1,1] if counter == 6
replace female_se = r(table)[2,1] if counter == 6
replace year_graph = 2011 if counter == 6
replace group = "Dem" if counter == 6
logit mistake female college age cnn maryland if year == 2013 & dem == 1
replace female_b = r(table)[1,1] if counter == 7
replace female_se = r(table)[2,1] if counter == 7
replace year_graph = 2013 if counter == 7
replace group = "Dem" if counter == 7
logit mistake female college age cnn maryland if year == 2014 & dem == 1
replace female_b = r(table)[1,1] if counter == 8
replace female_se = r(table)[2,1] if counter == 8
replace year_graph = 2014 if counter == 8
replace group = "Dem" if counter == 8
logit mistake female college age cnn maryland if year == 2015 & dem == 1
replace female_b = r(table)[1,1] if counter == 9
replace female_se = r(table)[2,1] if counter == 9
replace year_graph = 2015 if counter == 9
replace group = "Dem" if counter == 9
serrbar female_b female_se year_graph if group=="Dem", scale(1.96) xlabel(2004 2007 2008 2009 2010 2011 2013 2014 2015, angle(90)) ti("Democrats", size(medsmall)) xtitle(" " "Year", size(small)) ylabel(-1 -.5 0 .5 1 1.5) ytitle("Gender coefficient" " ") yline(0) graphregion(color(white)) mvopts(mcolor(black)) lcolor(black) saving(afg_dem.gph, replace) yscale(range(-1.2 1.75))

* GOP *
use "All Afghanistan mistake data appended.dta", clear
gen counter = _n
gen female_b = .
gen female_se = .
gen female_u = .
gen group = ""
gen year_graph = .

logit mistake female college age cnn maryland if year == 2004 & gop == 1
replace female_b = r(table)[1,1] if counter == 1
replace female_se = r(table)[2,1] if counter == 1
replace year_graph = 2004 if counter == 1
replace group = "Gop" if counter == 1
logit mistake female college age cnn maryland if year == 2007 & gop == 1
replace female_b = r(table)[1,1] if counter == 2
replace female_se = r(table)[2,1] if counter == 2
replace year_graph = 2007 if counter == 2
replace group = "Gop" if counter == 2
logit mistake female college age cnn maryland if year == 2008 & gop == 1
replace female_b = r(table)[1,1] if counter == 3
replace female_se = r(table)[2,1] if counter == 3
replace year_graph = 2008 if counter == 3
replace group = "Gop" if counter == 3
logit mistake female college age cnn maryland if year == 2009 & gop == 1
replace female_b = r(table)[1,1] if counter == 4
replace female_se = r(table)[2,1] if counter == 4
replace year_graph = 2009 if counter == 4
replace group = "Gop" if counter == 4
logit mistake female college age cnn maryland if year == 2010 & gop == 1
replace female_b = r(table)[1,1] if counter == 5
replace female_se = r(table)[2,1] if counter == 5
replace year_graph = 2010 if counter == 5
replace group = "Gop" if counter == 5
logit mistake female college age cnn maryland if year == 2011 & gop == 1
replace female_b = r(table)[1,1] if counter == 6
replace female_se = r(table)[2,1] if counter == 6
replace year_graph = 2011 if counter == 6
replace group = "Gop" if counter == 6
logit mistake female college age cnn maryland if year == 2013 & gop == 1
replace female_b = r(table)[1,1] if counter == 7
replace female_se = r(table)[2,1] if counter == 7
replace year_graph = 2013 if counter == 7
replace group = "Gop" if counter == 7
logit mistake female college age cnn maryland if year == 2014 & gop == 1
replace female_b = r(table)[1,1] if counter == 8
replace female_se = r(table)[2,1] if counter == 8
replace year_graph = 2014 if counter == 8
replace group = "Gop" if counter == 8
logit mistake female college age cnn maryland if year == 2015 & gop == 1
replace female_b = r(table)[1,1] if counter == 9
replace female_se = r(table)[2,1] if counter == 9
replace year_graph = 2015 if counter == 9
replace group = "Gop" if counter == 9
serrbar female_b female_se year_graph if group=="Gop", scale(1.96) xlabel(2004 2007 2008 2009 2010 2011 2013 2014 2015, angle(90)) ti("Republicans", size(medsmall)) xtitle(" " "Year", size(small)) ylabel(-1 -.5 0 .5 1 1.5) ytitle("Gender coefficient" " ") yline(0) graphregion(color(white)) saving(afg_gop.gph, replace) yscale(range(-1.2 1.75)) mvopts(mcolor(black)) lcolor(black)


* Independents *
use "All Afghanistan mistake data appended.dta", clear
gen counter = _n
gen female_b = .
gen female_se = .
gen female_u = .
gen group = ""
gen year_graph = .

logit mistake female college age cnn maryland if year == 2004 & ind == 1
replace female_b = r(table)[1,1] if counter == 1
replace female_se = r(table)[2,1] if counter == 1
replace year_graph = 2004 if counter == 1
replace group = "Ind" if counter == 1
logit mistake female college age cnn maryland if year == 2007 & ind == 1
replace female_b = r(table)[1,1] if counter == 2
replace female_se = r(table)[2,1] if counter == 2
replace year_graph = 2007 if counter == 2
replace group = "Ind" if counter == 2
logit mistake female college age cnn maryland if year == 2008 & ind == 1
replace female_b = r(table)[1,1] if counter == 3
replace female_se = r(table)[2,1] if counter == 3
replace year_graph = 2008 if counter == 3
replace group = "Ind" if counter == 3
logit mistake female college age cnn maryland if year == 2009 & ind == 1
replace female_b = r(table)[1,1] if counter == 4
replace female_se = r(table)[2,1] if counter == 4
replace year_graph = 2009 if counter == 4
replace group = "Ind" if counter == 4
logit mistake female college age cnn maryland if year == 2010 & ind == 1
replace female_b = r(table)[1,1] if counter == 5
replace female_se = r(table)[2,1] if counter == 5
replace year_graph = 2010 if counter == 5
replace group = "Ind" if counter == 5
logit mistake female college age cnn maryland if year == 2011 & ind == 1
replace female_b = r(table)[1,1] if counter == 6
replace female_se = r(table)[2,1] if counter == 6
replace year_graph = 2011 if counter == 6
replace group = "Ind" if counter == 6
logit mistake female college age cnn maryland if year == 2013 & ind == 1
replace female_b = r(table)[1,1] if counter == 7
replace female_se = r(table)[2,1] if counter == 7
replace year_graph = 2013 if counter == 7
replace group = "Ind" if counter == 7
logit mistake female college age cnn maryland if year == 2014 & ind == 1
replace female_b = r(table)[1,1] if counter == 8
replace female_se = r(table)[2,1] if counter == 8
replace year_graph = 2014 if counter == 8
replace group = "Ind" if counter == 8
logit mistake female college age cnn maryland if year == 2015 & ind == 1
replace female_b = r(table)[1,1] if counter == 9
replace female_se = r(table)[2,1] if counter == 9
replace year_graph = 2015 if counter == 9
replace group = "Ind" if counter == 9
serrbar female_b female_se year_graph if group=="Ind", scale(1.96) xlabel(2004 2007 2008 2009 2010 2011 2013 2014 2015, angle(90)) ti("Independents", size(medsmall)) xtitle(" " "Year", size(small)) ylabel(-1 -.5 0 .5 1 1.5) ytitle("Gender coefficient" " ") yline(0) graphregion(color(white)) mcolor(black) saving(afg_ind.gph, replace) yscale(range(-1.2 1.75)) mvopts(mcolor(black)) lcolor(black)

graph combine "afg_all.gph" "afg_dem.gph" "afg_gop.gph" "afg_ind.gph", graphregion(color(white))

* Figure 4 *
use "ABC_WaPo_Fall_2021.dta", clear

gen withdraw3 = q20
recode withdraw3 (8=.) (9=.)
gen education = educnew
gen age = q910
recode age (99=.)
gen female = 0
replace female = 1 if q921 == 2
gen white = 0
gen black = 0
gen hispanic = 0
replace white = 1 if racenet == 1
replace black = 1 if racenet == 2
replace hispanic = 1 if racenet == 3
gen gop3 = 0
gen dem3 = 0
replace gop3 = 1 if q901 == 2
replace dem3 = 1 if q901 == 1
gen gop5 = 0
gen dem5 = 0
replace gop5 = 1 if partlean == 2
replace dem5 = 1 if partlean == 1

mlogit withdraw3 female education age white
margins, dydx(female)
marginsplot, recast(scatter) graphregion(color(white)) xscale(range(.75 3.25)) yline(0) ti("") xti("") plotopts(mcolor(black)) ciopts(lcolor(black)) xlabel(1 "Approve of both" 2 "Approve withdrawal, not Biden" 3 "Disapprove" ) yti("Predicted Difference in Probability" "(Female vs. Male)" " ") ti("No Partisan Controls") saving(fig4_top.gph, replace)

mlogit withdraw3 female education age white gop5 dem5
margins, dydx(female)
marginsplot, recast(scatter) graphregion(color(white)) xscale(range(.75 3.25)) yline(0) ti("") xti("") plotopts(mcolor(black)) ciopts(lcolor(black)) xlabel(1 "Approve of both" 2 "Approve withdrawal, not Biden" 3 "Disapprove" ) yti("Predicted Difference in Probability" "(Female vs. Male)" " ") ti("With Partisan Controls") saving(fig4_bottom.gph, replace)

graph combine "fig4_top.gph" "fig4_bottom.gph", graphregion(color(white)) rows(2) cols(1) xsize(8.5) ysize(11)




